<%-- 
    Document   : rssorttable
    Created on : Oct 28, 2011, 9:10:42 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT, Beans.KhuVuc,Models.ThamSoHT_Model,Models.Ban_Model, Models.KhuVuc_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'msgservice', 'areaname', 'notice', 'rightmsg', 'order','status','tablelist','enable','disable', 'tablename', 'all', 'numberofseat' "; // chuỗi chứa các mã tham số của trang này.
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String areaname = mdsts[1].getTenTS();
            String disable = mdsts[2].getTenTS();
            String enable = mdsts[3].getTenTS();
            String msgservice = mdsts[4].getTenTS();
            String notice = mdsts[5].getTenTS();
            String numberofseat = mdsts[6].getTenTS();
            String order = mdsts[7].getTenTS();
            String rightmsg = mdsts[8].getTenTS();
            String status = mdsts[9].getTenTS();
            String tablelist = mdsts[10].getTenTS();
            String tablename = mdsts[11].getTenTS();
            String msgright = notice + "/" + rightmsg;
            String servicemsg = notice + "/" + msgservice;

            Vector v = (Vector) request.getAttribute("DSBan");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String ud1 = "";
            String ud2 = "";
            if (sapxep.equals("desc") ) {
                sx1 = "down";
                sx2 = "down";
                ud1 = "down1";
                ud2 = "down2";
            }  else if (sapxep.equals("asc") && test.equals("1")) {
                sx1 = "up";
                sx2 = "down";
                ud1 = "up1";
                ud2 = "down2";
            } else {
                sx1 = "down";
                sx2 = "up";
                ud1 = "down1";
                ud2 = "up2";
            }
%>


<div class="title">
    <%=tablelist%>
    
</div>        
<div class="content">
    <form name="dsban" action="">
        <table class="mytable" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th style=" width: 12%;"><%=order%></th>
                    <th style=" width: 27%;">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1%>" lang="<%=msgright%>"  name="1" onclick="BanSortTenKV( this.className, this.name, this.lang)">
                            <div style="float:left"><%=areaname%></div>
                            <div id="sortkv1" class="<%=ud1%>"></div>
                        </a>
                    </th>
                    <th style=" width: 15%;"><%=tablename%></th>
                    <th style=" width: 15%;"><%=numberofseat%></th>
                    <th style="margin-top: 2px;">
                        <a href="#" id="titledskv2" class="<%=sx2%>"  name="1" lang="<%=msgright%>" onclick="BanSortTTKV(this.className, this.name, this.lang)">
                            <div><%=status%></div>
                            <div >
                                <div id="sortkv2" class="<%=ud2%>"></div>
                            </div>
                        </a>
                    </th>
                </tr>
                <tr id="searchTenKV" >
                    <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchBan(this.alt, this.lang)"></th>
                    <th >
                        <input type="textbox" style="width: 95px;" name="TENKV" class="tenkv text" alt="1" size="13" lang="<%=msgright%>" >
                    </th>
                    <th><input type="textbox" style="width: 50px;" name="TENBAN" maxlength="3" alt="1" class="tenban text" size="4" lang="<%=msgright%>"  onkeypress="return keypress(event)"></th>
                    <th><input type="textbox" style="width: 50px;" name="SOGHE" maxlength="3" alt="1" class="soghe text" size="4" lang="<%=msgright%>" onkeypress="return keypress(event)"></th>
                    <th>
                        <select class="select" name="TINHTRANG" id="1" lang="<%=msgright%>" onchange="SearchBan(this.id, this.lang)">
                            <option value="all"><%= all%></option>
                            <option value="1"><%=enable%></option>
                            <option value="0"><%=disable%></option>
                        </select>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                                Beans.Ban b = (Beans.Ban) v.elementAt(i);
                %>
                <tr>
                    <td class="STT"><%= i + 1%></td>
                    <td>
                            <select onchange="UpdateKVBan(this.value, this.id, this.lang)" id="<%=b.getMaBan() %>" lang="<%=msgright%>">
                                <option value="<%=b.getMaKV()%>"><%=Ban_Model.LayTenKV(b.getMaKV(), langid)%></option>
                                <%
                                    KhuVuc[] dskv = KhuVuc_Model.DSKhuVuc(b.getMaKV(), langid);
                                    for (int j = 0; j < dskv.length; j++) {%>
                                        <option value="<%=dskv[j].getMaKV() %>"><%=dskv[j].getTenKV() %></option>
                                <%  }%>
                            </select>
                        </td>
                    <td style=" padding-left: 15px;"><%=b.getTenBan()%></td>
                    <td style=" padding-left: 15px;"><%=b.getSoGhe()%></td>
                    <td>
                        <select  class="<%= b.getMaBan()%>" lang="<%=msgright%>" name="<%=b.getMaTTBan() %>" id="<%=servicemsg%>" onchange="UpdateStatusBan(this.value,  this.className, this.lang, this.name, this.id)">
                            <%
                                                                            if (b.getTinhTrang() == 1) {%>
                            <option value="1"><%= enable%></option>
                            <option value="0"><%= disable%></option>
                            <%  } else {%>
                            <option value="0"><%= disable%></option>
                            <option value="1"><%= enable%></option>
                            <%  }
                            %>
                        </select>
                    </td>
                </tr>
                <%  }
                %>
            </tbody>
        </table>
        <div class="pagination">
            <%
                        int trang = 1;
                        if (item > 1) {
                            trang = item - 1;
                        }
            %>
            <%
                                if (vsize > 10) {%>
            <%
                                                        if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="BanSortTenKV(this.id, this.name, this.lang)">«</a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="BanSortTTKV(this.id, this.name, this.lang)">«</a>
            <%  }
            %>
            <%
                                                for (int c = 1; c <= numpage; c++) {
                                                    if (numpage < 10) {
                                                        if (c != item) {%>
            <%
                                                                                        if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%=c%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%=c%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%=c%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%=c%></a>
            <%  }
            %>
            <%                } else {%>
            <a class="current"> <%= c%></a>
            <%                }
                                                                                } else {
                                                                                    if (c == item && item == 1) {%>
            <%
                                                                                  if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current" name="<%= item%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current" name="<%= item%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  }
            %>

            <%            }
                                                                                    if (c == item && item != 1) {
                                                                                        if (item < (numpage / 2)) {%>
            <%
                                                                                      if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= numpage%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  }
            %>

            <%                }%>
            <%                                     if (item >= (numpage / 2) && item != numpage) {
                                                                              int start = 1;
            %>
            <%
                                                             if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= start + 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>" lang="<%=msgright%>" name="<%= start + 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item + 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  }
            %>

            <%                }
            %>
            <%                                     if (item >= (numpage / 2) && item == numpage) {
                                                                              int start = 1;
            %>
            <%
                                                             if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 3%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 2%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTenKV(this.id, this.name, this.lang)"><%= item%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= start + 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 3%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 2%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>"  name="<%= item - 1%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="BanSortTTKV(this.id, this.name, this.lang)"><%= item%></a>
            <%  }
            %>
            <%                }
            %>
            <%            }
                                                    }
                                                }
            %>
            <%
                                                if (item + 1 <= numpage) {
                                                    trang = item + 1;
                                                } else {
                                                    trang = item;
                                                }
            %>
            <%
                                                        if (sortkv.equals("tenkv")) {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="BanSortTenKV(this.id, this.name, this.lang)">»</a>
            <%  } else {%>
            <a href="#" id="<%=sort%>" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="BanSortTTKV(this.id, this.name, this.lang)">»</a>
            <%  }
            %>
            <%  }
            %>
        </div>
    </form>
</div>


